﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Romeo.Data;

namespace Romeo.WinForms
{
    public partial class EvaluationStatisticsDisplay : UserControl
    {
        public EvaluationStatisticsDisplay ()
        {
            InitializeComponent ();
        }

        private string IntToStr (long aValue)
        {
            int exp = 0;

            while (exp < 4 && aValue > 500000)
            {
                exp++;
                aValue /= 1000;
            }

            string n = aValue.ToString ();
            if (n.Length > 4)
            {
                int k = n.Length - 3;
                n = n.Substring (0, k) + "." + n.Substring (k, 3);
            }

            switch (exp)
            {
                case 4:
                    return n + " T";
                case 3:
                    return n + " G";
                case 2:
                    return n + " M";
                case 1:
                    return n + "K";
                default:
                    return n;
            }
        }

        public void Display (EvaluationStatistics aStats)
        {
            text_Moves.Text = IntToStr (aStats.EvaluatedMoves);
            text_Mid.Text = IntToStr (aStats.EvaluatedMidPositions);
            text_End.Text = IntToStr (aStats.EvaluatedEndPositions);
            text_Alpha.Text = IntToStr (aStats.AlphaBetaPrunes);
        }
    }
}
